package com.jymj.service.impl;

import com.jymj.dao.ApplyFileDao;
import com.jymj.entity.zjd.ApplyFileEntity;
import com.jymj.service.ApplyFileService;
import com.jymj.utils.FileUtile.FileUploadEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by ljj on 2018/9/12.
 */
@Service
public class ApplyFileServiceImpl implements ApplyFileService {
    @Autowired
    private ApplyFileDao applyFileDao;

    @Override
    public ApplyFileEntity save(FileUploadEntity fileUploadEntity,Integer cltype) {
        ApplyFileEntity applyFileEntity = new ApplyFileEntity();
        applyFileEntity.setFileName(fileUploadEntity.getFileName())
                .setUrl(fileUploadEntity.getDataUrl())
                .setUpdate(new Date())
                .setAppId(-1)
                .setYlId(-1)
                .setCltype(cltype);
        applyFileDao.save(applyFileEntity);
        return applyFileEntity;
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        applyFileDao.deleteBatch(ids);
    }

    @Override
    public ApplyFileEntity queryObject(Integer id) {
        return applyFileDao.queryObject(id);
    }

    @Override
    public void delete(Integer id) {
        applyFileDao.delete(id);
    }

    @Override
    public List<ApplyFileEntity> queryListByYlid(Integer[] ylIds) {
        return applyFileDao.queryListByYlid(ylIds);
    }

    @Override
    public void deleteBatchByYlid(Integer[] ylIds) {
        applyFileDao.deleteBatchByYlid(ylIds);
    }

    @Override
    public void update(ApplyFileEntity applyFileEntity) {
        applyFileDao.update(applyFileEntity);
    }

    @Override
    public ApplyFileEntity getByYlid(Integer id) {
        return applyFileDao.getByYlid(id);
    }

    @Override
    public void saveFiles(List<ApplyFileEntity> applyFileEntities, Integer id) {
        applyFileDao.saveFiles(applyFileEntities,id);
    }
}
